home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / f90 / trimlen.z / trimlen
Encoding:
Text File  |  1998-10-30  |  2.9 KB  |  68 lines

  1. TRIMLEN(3F)                                            Last changed: 3-3-97
  2.  
  3.  
  4. NNAAMMEE
  5.      TTRRIIMMLLEENN - Returns the length of a character argument without counting
  6.      trailing blanks
  7.  
  8. SSYYNNOOPPSSIISS
  9.      IINNTTEEGGEERR _t_r_i_m_l_e_n
  10.      _i_n_t_l_e_n == TTRRIIMMLLEENN((_s_t_r_i_n_g))
  11.  
  12. IIMMPPLLEEMMEENNTTAATTIIOONN
  13.      UNICOS, UNICOS/mk, and IRIX systems
  14.  
  15. DDEESSCCRRIIPPTTIIOONN
  16.      TTRRIIMMLLEENN is an integer function that returns the length of a character
  17.      argument without counting the trailing blanks.  The function must be
  18.      declared as type integer in the calling routine.  The _s_t_r_i_n_g argument
  19.      must be of type character.
  20.  
  21.      This function is intended for use as part of the substring notation.
  22.      Examples 2 and 3 show the TTRRIIMMLLEENN function used in this manner.  The
  23.      value of each of the parts of the substring notation must be as
  24.      follows:
  25.  
  26.           1 <= _l_e_f_t_m_o_s_t_p_o_s <= _r_i_g_h_t_m_o_s_t_p_o_s <= _s_t_r_i_n_g_l_e_n_g_t_h
  27.  
  28.      _l_e_f_t_m_o_s_t_p_o_s is the leftmost character position in the substring,
  29.      _r_i_g_h_t_m_o_s_t_p_o_s is the rightmost character position in the substring, and
  30.      _s_t_r_i_n_g_l_e_n_g_t_h is the declared length of the character entity.  TTRRIIMMLLEENN
  31.      returns a value of 1 for a string of all blanks.
  32.  
  33. EEXXAAMMPPLLEESS
  34.      Example 1:  A program using the function TTRRIIMMLLEENN could do the
  35.      following:
  36.  
  37.             INTEGER TRIMLEN
  38.             CHARACTER*80 STRING
  39.             STRING = ' '
  40.             STRING(20:47) = 'TEST TRIMLEN LENGTH RETURNED'
  41.             INTLEN = TRIMLEN(STRING)
  42.             WRITE(6,1) INTLEN, STRING(1:INTLEN)
  43.           1 FORMAT(' LENGTH=',I5,' STRING=',A,'-DONE')
  44.             PRINT 2,'12345678901234567890123456789012345678901234567890'
  45.           2 FORMAT(21X,A)
  46.             END
  47.  
  48.      The output of the program is as follows:
  49.  
  50.       LENGTH=  47 STRING=                 TEST TRIMLEN LENGTH RETURNED-DONE
  51.                        12345678901234567890123456789012345678901234567890
  52.  
  53.      Example 2:  This example produces a string with the character <<
  54.      written following the last nonblank character of SSTTRRIINNGG:
  55.  
  56.               WRITE(6,901)STRING(1:TRIMLEN(STRING))
  57.           901 FORMAT(' The string is >',A,'<')
  58.  
  59.      Example 3:  In this example, although NNEEWW may have trailing blanks,
  60.      the character << is written after the last nonblank character in
  61.      SSTTRRIINNGG:
  62.  
  63.           NEW = STRING(1:TRIMLEN(STRING)) // '< The end'
  64.  
  65. SSEEEE AALLSSOO
  66.      _A_p_p_l_i_c_a_t_i_o_n _P_r_o_g_r_a_m_m_e_r'_s _L_i_b_r_a_r_y _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, publication SR-
  67.      2165, for the printed version of this man page.
  68.